<?php

namespace app\index\validate;

use think\Validate;

class CertBorrow extends Validate
{

    protected $rule = [
        'id' => 'require|number',
        'type' => 'require',
        'borrow_type' => 'require',
        'receive_type' => 'require',
        'list' => 'require|checkList',
    ];

    protected $message = [
        'id' => '网络错误',
        'type' => '请选择借证种类',
        'borrow_type' => '请选择借证类型',
        'receive_type' => '请选择领取方式',
        'list' => '请填写明细',
    ];

    protected $scene = [
        'add' => ['type','borrow_type','list'],
        'edit' => ['id','type','borrow_type','list'],
    ];

    function checkList($value, $rule, $data){
        if(count($value) === 1){
            return '请填写明细';
        }
        return true;
    }

}

